<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:xhtml />
<script type="text/javascript">
    function getPhenotypes()
    {
        if ($("[name=selectedCohort] option:selected").length <= 0)
        {
            return false;
        }
        $("select[name=selectedPhenotype]").empty();
        $.ajax({
            url: "analysisAjax.do",
            data: {request: 'phenotype',
                   selectedCohort: $("[name=selectedCohort]").val()},
            success: function(data) {
                $("select[name=selectedPhenotype]").append(data);
            },
            error: function() {
                $("select[name=selectedPhenotype]").append('<option value="-1">Error on the server. Please reset cohorts.</option>');
            }
        });
    }

    $(document).ready(function() {
        // Ajax call binding
        $("select[name=selectedCohort]").change(function() {
            getPhenotypes();
        });

        getPhenotypes();
    });
</script>
<div id="cut" class="content input">
    <h2>Cut Continous Variables</h2>
    <html:form action="/cutSubmit">
        <dl>
            <dt>Cohorts:</dt>
            <dd>
                <html:select property="selectedCohort">
                    <html:optionsCollection property="cohorts" value="cohortID" label="name" />
                </html:select>
            </dd>
            <dt>Subject Filter:</dt>
            <dd>
                <html:checkbox styleId="removeDuplicateSubjects" property="removeDuplicateSubjects" />
                <label for="removeDuplicateSubjects">Remove Duplicate Subjects</label><br />
                <html:checkbox styleId="removeMzTwins" property="removeMzTwins" />
                <label for="removeMzTwins">Remove MZ Twins</label>
            </dd>
            <dt>Phenotypes:</dt>
            <dd>
                <html:select property="selectedPhenotype">
                    <html:option value="-1">Please select cohort(s).</html:option>
                </html:select>
            </dd>
            <dt>Cut Point:</dt>
            <dd>
                <html:select property="cutType">
                    <html:options property="availableCutType" />
                </html:select>
                <html:text property="cutValue" size="5" />
            </dd>
            <dt>Genes to include:</dt>
            <dd>
                <html:select property="selectedGenes" size="8" multiple="multiple">
                    <html:optionsCollection property="availableGenes" value="geneID" label="name"/>
                </html:select>
            </dd>
            <dt>Email:</dt>
            <dd><html:text property="email"/></dd>
        </dl>
        <p><html:submit property="submitType" value="Submit" /></p>
    </html:form>
</div>